Method and device for encoding/decoding images

ABSTRACT

A method and a device for encoding/decoding images are disclosed. The method for encoding images comprises the steps of: deriving a scan type of a residual signal for a current block according to whether or not the current block is a transform skip block; and applying the scan type to the residual signal for the current block, wherein the transform skip block is a block to which transform for the current block is not applied and is specified on the basis of information indicating whether or not transform for the current block is to be applied.

CROSS-REFERENCE TO RELATED APPLICATIONS

This application is a continuation of U.S. patent application Ser. No.16/413,870 filed on May 16, 2019, which is a continuation of U.S. patentapplication Ser. No. 15/630,821 filed on Jun. 22, 2017, now U.S. Pat.No. 10,331,661 issued on Jul. 2, 2019, which is a continuation of U.S.patent application Ser. No. 15/255,035 filed on Sep. 1, 2016, now U.S.Pat. No. 9,723,311 issued on Aug. 1, 2017, which is a continuation ofU.S. patent application Ser. No. 14/406,438 having a 371(c) date of Dec.8, 2014, now U.S. Pat. No. 9,497,465 issued on Nov. 15, 2016, which is aU.S. national stage application of International Application No.PCT/KR2013/005616 filed on Jun. 25, 2013, which claims the benefit ofKorean Patent Applications Nos. 10-2012-0071446 and 10-2013-0073067,filed on Jun. 29, 2012 and Jun. 25, 2013, respectively, in the KoreanIntellectual Property Office, the entire disclosures of which areincorporated herein by reference for all purposes.

TECHNICAL FIELD

The present invention relates to the encoding and decoding of an imageand, more particularly, to a method of scanning residual signals.

BACKGROUND ART

Broadcast service having High Definition (HD) resolution (1280×1024 or1920×1080) is extended nationwide and globally. Accordingly, many usersare accustomed to video having high resolution and high picture quality.Accordingly, a lot of institutes are giving impetus to the developmentof the next-generation image device. Furthermore, as there is a growinginterest in Ultra High Definition (UHD) having resolution 4 times higherthan that of HDTV along with HDTV, moving image standardizationorganizations have become recognized a need for compression technologyfor an image having higher resolution and higher picture quality.Furthermore, there is an urgent need for a new standard which canmaintain the same picture quality and also have many advantages in termsof a frequency band or storage through higher compression efficiencythan that of H.264/AVC that is now used in HDTV, mobile phones, and Blueray players.

Today, Moving Picture Experts Group (MPEG) and Video Coding ExpertsGroup (VCEG) are jointly standardizing High Efficiency Video Coding(HEVC), that is, the next-generation video codec, and are aiming toencode an image including a UHD image with compression efficiency twicethan that of H.264/AVC. This can provide an image having a lowerfrequency than and higher picture quality than a current image even in3D broadcasting and a mobile communication network as well as HD and UHDimages.

DISCLOSURE Technical Problem

The present invention provides a method and apparatus for encoding anddecoding an image, which are capable of improving encoding and decodingefficiency.

The present invention provides a method and apparatus for scanningresidual signals, which are capable of improving encoding and decodingefficiency.

Technical Solution

In accordance with an aspect of the present invention, there is providedan image decoding method. The method includes deriving a scan type forthe residual signals of a current block depending on whether or not thecurrent block is a transform skip block and applying the scan type tothe residual signals of the current block, wherein the transform skipblock is the current block to which transform has not been applied andis specified based on information indicating whether or not to apply thetransform to the current block.

The deriving of the scan type for the residual signals of the currentblock may include driving any one of a vertical scan, a horizontal scan,and an up-right scan as the scan type for the residual signals if thecurrent block is a transform skip block.

The deriving of the scan type for the residual signals of the currentblock may include setting a scan type, derived based on anintra-prediction mode of the current block, as the scan type for theresidual signals if the current block is a transform skip block.

A horizontal scan may be set again as the scan type for the residualsignals if the scan type derived based on the intra-prediction mode ofthe current block is a vertical scan.

A vertical scan may be set again as the scan type for the residualsignals if the scan type derived based on the intra-prediction mode ofthe current block is a horizontal scan.

An up-right scan may be set again as the scan type for the residualsignals if the scan type derived based on the intra-prediction mode ofthe current block is not a vertical scan or a horizontal scan.

The deriving of the scan type for the residual signals of the currentblock may include deriving any one of a vertical scan, a horizontalscan, and an up-right scan as the scan type for the residual signals ofthe current block if the current block is a transform skip block and asize of the current block is a specific size or lower.

The specific size may be a 4×4 size.

The deriving of the scan type for the residual signals of the currentblock may include setting a scan type, deriving based on anintra-prediction mode of the current block, again if the current blockis a transform skip block and a size of the current block is a specificsize or lower.

A horizontal scan may be set again as the scan type for the residualsignals if the scan type derived based on the intra-prediction mode ofthe current block is a vertical scan.

A vertical scan may be set again as the scan type for the residualsignals if the scan type derived based on the intra-prediction mode ofthe current block is a horizontal scan.

An up-right scan may be set again as the scan type for the residualsignals if the scan type derived based on the intra-prediction mode ofthe current block is not a vertical scan or a horizontal scan.

The specific size may be a 4×4 size.

The deriving of the scan type for the residual signals of the currentblock may include deriving the scan type for the residual signals of thecurrent block based on an intra-prediction mode of the current block ifthe current block is not a transform skip block.

In accordance with another aspect of the present invention, there isprovided an image decoding apparatus. The apparatus include a scan typederiving module for deriving a scan type for residual signals of acurrent block depending on whether or not the current block is atransform skip block and a scanning module for applying the scan type tothe residual signals of the current block, wherein the transform skipblock is the current block to which transform has not been applied andis specified based on information indicating whether or not to apply thetransform to the current block.

In accordance with yet another aspect of the present invention, there isprovided an image encoding method. The method includes deriving a scantype for residual signals of a current block depending on whether or notthe current block is a transform skip block and applying the scan typeto the residual signals of the current block, wherein the transform skipblock is the current block to which transform has not been applied andis specified based on information indicating whether or not to apply thetransform to the current block.

In accordance with further yet another aspect of the present invention,there is provided an image encoding apparatus. The apparatus includes ascan type deriving module for deriving a scan type for residual signalsof a current block depending on whether or not the current block is atransform skip block and a scanning module for applying the scan type tothe residual signals of the current block, wherein the transform skipblock is the current block to which transform has not been applied andis specified based on information indicating whether or not to apply thetransform to the current block.

Advantageous Effects

Since a transform process is not performed on a block to which atransform skip algorithm has been applied, a block on which an existingtransform process has been performed and the transform skip block havedifferent transform coefficient characteristics. Accordingly, encodingand decoding efficiency for residual signals can be improved byproviding a method and apparatus for deriving a scan type, which aresuitable for the characteristics of a transform skip block, not atransform coefficient scan method applied to a block on which anexisting transform process has been performed.

DESCRIPTION OF DRAWINGS

FIG. 1 is a block diagram showing the construction of an image encodingapparatus to which an embodiment of the present invention is applied;

FIG. 2 is a block diagram showing the construction of an image decodingapparatus to which an embodiment of the present invention is applied;

FIG. 3 is a diagram schematically showing the partition structure of animage when encoding the image;

FIG. 4 is a diagram showing the forms of a PU that may be included in aCU;

FIG. 5 is a diagram showing the forms of a TU that may be included in aCU;

FIG. 6 is a diagram showing an example of intra-prediction modes;

FIG. 7 is a diagram showing an example of an up-right scan method fortransform coefficients;

FIG. 8 is a flowchart illustrating an embodiment of a method fordetermining a scan type according to an intra-prediction mode;

FIG. 9 is a flowchart illustrating an example of a method of selecting afrequency transform method for residual signals (or residual image);

FIG. 10 is a flowchart illustrating a method of deriving a scan type forresidual signals (or transform coefficients) in accordance with anembodiment of the present invention;

FIG. 11 is a flowchart illustrating a method of deriving a scan type forresidual signals (or transform coefficients) in accordance with anotherembodiment of the present invention;

FIG. 12 is a diagram showing examples of scan types to which the presentinvention can be applied;

FIG. 13 is a flowchart illustrating a method of deriving a scan type forresidual signals (or transform coefficients) in accordance with anembodiment of the present invention;

FIG. 14 is a flowchart illustrating a method of deriving a scan type forresidual signals (or transform coefficients) in accordance with anotherembodiment of the present invention;

FIG. 15 is a diagram showing an example of a difference in theresolution between a luma block and a chroma block;

FIG. 16 is a diagram showing another example of a difference in theresolution between a luma block and a chroma block;

FIG. 17 is a schematic block diagram of an encoding apparatus inaccordance with an embodiment of the present invention; and

FIG. 18 is a schematic block diagram of a decoding apparatus inaccordance with an embodiment of the present invention.

MODE FOR INVENTION

Hereinafter, some exemplary embodiments of the present invention aredescribed in detail with reference to the accompanying drawings.Furthermore, in describing the embodiments of this specification, adetailed description of the known functions and constitutions will beomitted if it is deemed to make the gist of the present inventionunnecessarily vague.

In this specification, when it is said that one element is connected orcoupled with the other element, it may mean that the one element may bedirectly connected or coupled with the other element or a third elementmay be connected or coupled between the two elements. Furthermore, inthis specification, when it is said that a specific element is included,it may mean that elements other than the specific element are notexcluded and that additional elements may be included in the embodimentsof the present invention or the scope of the technical spirit of thepresent invention.

Terms, such as the first and the second, may be used to describe variouselements, but the elements are not restricted by the terms. The termsare used to only distinguish one element from the other element. Forexample, a first element may be named a second element without departingfrom the scope of the present invention. Likewise, a second element maybe named a first element.

Furthermore, element units described in the embodiments of the presentinvention are independently shown to indicate difference andcharacteristic functions, and it does not mean that each of the elementunits is formed of a piece of separate hardware or a piece of software.That is, the element units are arranged and included, for convenience ofdescription, and at least two of the element units may form one elementunit or one element may be divided into a plurality of element units andthe plurality of divided element units may perform functions. Anembodiment into which the elements are integrated or embodiments fromwhich some elements are separated are also included in the scope of thepresent invention, unless they depart from the essence of the presentinvention.

Furthermore, in the present invention, some elements are not essentialelements for performing essential functions, but may be optionalelements for improving only performance. The present invention may beimplemented using only essential elements for implementing the essenceof the present invention other than elements used to improve onlyperformance, and a structure including only essential elements otherthan optional elements used to improve only performance is included inthe scope of the present invention.

FIG. 1 is a block diagram showing the construction of an image encodingapparatus to which an embodiment of the present invention is applied.

Referring to FIG. 1, the image encoding apparatus 100 includes a motionestimation module 111, a motion compensation module 112, anintra-prediction module 120, a switch 115, a subtractor 125, a transformmodule 130, a quantization module 140, an entropy encoding module 150,an inverse quantization module 160, an inverse transform module 170, anadder 175, a filter module 180, and a reference picture buffer 190.

The image encoding apparatus 100 can perform encoding on an input imagein intra-mode or inter-mode and output a bit stream. In the case ofintra-mode, the switch 115 can switch to intra mode. In the case ofinter-mode, the switch 115 can switch to inter-mode. Intra-predictionmeans intra-frame prediction, and inter-prediction means inter-frame.The image encoding apparatus 100 can generate a prediction block for theinput block of the input image and then encode a difference between theinput block and the prediction block. Here, the input image can mean theoriginal picture.

In the case of intra-mode, the intra-prediction module 120 can generatethe prediction block by performing spatial prediction using a value ofthe pixel of an already encoded block neighboring a current block.

In the case of inter-mode, the motion estimation module 111 can obtain amotion vector by searching a reference picture, stored in the referencepicture buffer 190, for a region that is most well matched with theinput block in a motion prediction process. The motion compensationmodule 112 can generate the prediction block by performing motioncompensation using the motion vector and the reference picture stored inthe reference picture buffer 190. Here, the motion vector is atwo-dimensional (2-D) vector used in inter-prediction, and the motionvector can indicate an offset between a picture to be nowencoded/decoded and a reference picture.

The subtractor 125 can generate a residual block based on the differencebetween the input block and the generated prediction block.

The transform module 130 can perform transform on the residual block andoutput a transform coefficient according to the transformed block.Furthermore, the quantization module 140 can output a quantizedcoefficient by quantizing the received transform coefficient accordingto a quantization parameter.

The entropy encoding module 150 can perform entropy encoding on a symbolaccording to a probability distribution based on values calculated bythe quantization module 140, an encoding parameter value calculated inan encoding process, etc. and output a bit stream according to theentropy-coded symbols. If entropy encoding is applied, the size of a bitstream for a symbol to be encoded can be reduced because the symbol isrepresented by allocating a small number of bits to a symbol having ahigh incidence and a large number of bits to a symbol having a lowincidence. Accordingly, the compression performance of image encodingcan be improved through entropy encoding. The entropy encoding module150 can use such encoding methods as exponential Golomb,Context-Adaptive Binary Arithmetic Coding (CABAC), and Context-AdaptiveBinary Arithmetic Coding (CABAC) for the entropy encoding.

The image encoding apparatus 100 according to the embodiment of FIG. 1performs inter-prediction encoding, that is, inter-frame predictionencoding, and thus a picture that has been coded needs to be decoded andstored in order to be used as a reference picture. Accordingly, aquantized coefficient is dequantization by the dequantization module 160and inverse transformed by the inverse transform module 170. Thedequantized and inversely transformed coefficient is added to theprediction block through the adder 175, thereby generating areconstructed block.

The reconstructed block experiences the filter module 180. The filtermodule 180 can apply one or more of a deblocking filter, a SampleAdaptive Offset (SAO), and an Adaptive Loop Filter (ALF) to thereconstructed block or the reconstructed picture. The filter module 180may also be called an adaptive in-loop filter. The deblocking filter canremove block distortion generated at the boundary of blocks. The SAO canadd a proper offset value to a pixel value in order to compensate for acoding error. The ALF can perform filtering based on a value obtained bycomparing a reconstructed picture with the original picture. Thereconstructed block that has experienced the filter module 180 can bestored in the reference picture buffer 190.

FIG. 2 is a block diagram showing the construction of an image decodingapparatus to which an embodiment of the present invention is applied.

Referring to FIG. 2, the image decoding apparatus 200 includes anentropy decoding module 210, a dequantization module 220, an inversetransform module 230, an intra-prediction module 240, a motioncompensation module 250, a filter module 260, and a reference picturebuffer 270.

The image decoding apparatus 200 can receive a bit stream outputted froman encoder, perform decoding on the bit stream in intra-mode orinter-mode, and output a reconstructed image, that is, a reconstructedimage. In the case of intra-mode, a switch can switch to intra-mode. Inthe case of inter-mode, the switch can switch to inter-mode.

The image decoding apparatus 200 can obtain a reconstructed residualblock from the received bit stream, generate a prediction block, andgenerate a reconstructed block, that is, a restoration block, by addingthe reconstructed residual block to the prediction block.

The entropy decoding module 210 can generate symbols including a symbolhaving a quantized coefficient form by performing entropy decoding onthe received bit stream according to a probability distribution.

If an entropy decoding method is applied, the size of a bit stream foreach symbol can be reduced because the symbol is represented byallocating a small number of bits to a symbol having a high incidenceand a large number of bits to a symbol having a low incidence.

The quantized coefficient is dequantized by the dequantization module220 and is inversely transformed by the inverse transform module 230. Asa result of the dequantization/inverse transform of the quantizedcoefficient, a reconstructed residual block can be generated.

In the case of intra-mode, the intra-prediction module 240 can generatethe prediction block by performing spatial prediction using a value ofthe pixel of an already encoded block neighboring a current block. Inthe case of inter-mode, the motion compensation module 250 can generatethe prediction block by performing motion compensation using a motionvector and a reference picture stored in the reference picture buffer270.

The residual block and the prediction block are added together by anadder 255. The added block experiences the filter module 260. The filtermodule 260 can apply at least one of a deblocking filter, an SAO, and anALF to the reconstructed block or the reconstructed picture. The filtermodule 260 outputs a reconstructed image, that is, a reconstructedimage. The reconstructed image can be stored in the reference picturebuffer 270 and can be used for inter-frame prediction.

FIG. 3 is a diagram schematically showing the partition structure of animage when encoding the image.

In High Efficiency Video Coding (HEVC), encoding is performed in acoding unit in order to efficiency partition an image.

Referring to FIG. 3, in HEVC, an image 300 is sequentially partitionedin the Largest Coding Unit (hereinafter referred to as an LCU), and apartition structure is determined based on the LCUs. The partitionstructure means a distribution of Coding Units (hereinafter referred toas CUs) for efficiently encoding an image within the LCU 310. Thisdistribution can be determined based on whether or not one CU will bepartitioned into four CUs each reduced by half from the one CU in awidth size and a height size. Likewise, the partitioned CU can berecursively partitioned into four CUs each reduced by half from thepartitioned CU in a width size and a height size.

Here, the partition of a CU can be recursively performed up to apredetermined depth. Information about the depth is informationindicative of the size of a CU, and information about the depth of eachCU is stored. For example, the depth of an LCU can be 0, and the depthof the Smallest Coding Unit (SCU) can be a predetermined maximum depth.Here, the LCU is a CU having a maximum CU size as described above, andthe SCU is a CU having a minimum CU size.

Whenever partition is performed from the LCU 310 by half in a width sizeand a height size, the depth of a CU is increased by 1. A CU on whichpartitions has not been performed has a 2N×2N size for each depth, and aCU on which partition is performed is partitioned from a CU having a2N×2N size to four CUs each having an N×N size. The size of N is reducedby half whenever the depth is increased by 1.

Referring to FIG. 3, the size of the LCU having a minimum depth of 0 canbe 64×64 pixels, and the size of the SCU having a maximum depth of 3 canbe 8×8 pixels. Here, the LCU having 64×64 pixels can be represented by adepth of 0, a CU having 32×32 pixels can be represented by a depth of 1,a CU having 16×16 pixels can be represented by a depth of 2, and the SCUhaving 8×8 pixels can be represented by a depth of 3.

Furthermore, information about whether or not a specific CU will bepartitioned can be represented through partition information of 1 bitfor each CU. The partition information can be included in all CUs otherthan the SCU. For example, if a CU is not partitioned, partitioninformation of 0 can be stored. If a CU is partitioned, partitioninformation of 1 can be stored.

Meanwhile, a CU partitioned from the LCU can include a Prediction Unit(PU) (or Prediction Block (PB)), that is, a basic unit for prediction,and a Transform Unit (TU) (or Transform Block (TB)), that is, a basicunit for transform.

FIG. 4 is a diagram showing the forms of a PU that may be included in aCU.

A CU that is no longer partitioned, from among CUs partitioned from theLCU, is partitioned into one or more PUs. This behavior itself is alsocall partition. A Prediction Unit (hereinafter referred to as a PU) is abasic unit on which prediction is performed and encoded in any one ofskip mode, inter-mode, and intra mode. The PU can be partitioned invarious forms depending on each mode.

Referring to FIG. 4, in the case of skip mode, a 2N×2N mode 410 havingthe same size as a CU can be supported without partition within the CU.

In the case of inter-mode, 8 partitioned forms, for example, the 2N×2Nmode 410, a 2N×N mode 415, an N×2N mode 420, an N×N mode 425, a 2N×nUmode 430, a 2N×nD mode 435, an nLx2N mode 440, and an nR×2N mode 445 canbe supported within a CU.

In the case of intra-mode, the 2N×2N mode 410 and the N×N mode 425 canbe supported within a CU.

FIG. 5 is a diagram showing the forms of a TU that may be included in aCU.

A Transform Unit (hereinafter referred to as a TU) is a basic unit usedfor spatial transform and a quantization/dequantization (scaling)process within a CU. A TU can have a rectangular or square form. A CUthat is no longer partitioned, from among CUs partitioned from the LCU,can be partitioned into one or more TUs.

Here, the partition structure of the TU can be a quad-tree structure.For example, as shown in FIG. 5, one CU 510 can be partitioned once ormore depending on a quad-tree structure, so that the CU 510 is formed ofTUs having various sizes.

Meanwhile, in HEVC, as in H.264/AVC, intra-frame prediction (hereinaftercalled intra-prediction) encoding is performed. Here, predictionencoding is performed using neighboring blocks located near a currentblock depending on an intra-prediction mode (or prediction directivity)of the current block. In H.264/AVC, encoding is performed using aprediction mode having 9 directivities. In contrast, in HEVC, encodingis performed using a total of 36 prediction modes including 33directional prediction modes and 3 non-directional prediction modes.

FIG. 6 is a diagram showing an example of intra-prediction modes.Different mode numbers can be assigned to respective intra-predictionmode.

Referring to FIG. 6, a total of 36 intra-prediction modes are present.The total of 36 intra-prediction modes can include 33 directional modesand 3 non-directional modes depending on a direction in which referencepixels used to estimate a pixel value of a current block and/or aprediction method.

The 3 non-directional modes include a planar (Intra_Planar) mode, a DC(Intra_DC) mode, and an LM mode (Intra_FromLuma) in which a chromasignal is derived from a restored luma signal. In intra-prediction, allthe 3 non-directional modes may be used or some of them may be used. Forexample, only the planar mode and the DC mode may be used, and the LMmode may not be used.

Encoding for 36 intra-prediction modes, such as those shown in FIG. 6,can be applied to a luma signal and a chroma signal. For example, in thecase of a luma signal, modes other than the LM mode of the 36intra-prediction modes can be encoded. In the case of a chroma signal,an intra-prediction mode can be encoded using three methods as in Table1.

Table 1 is an example of an encoding method for an intra-prediction modeof a chroma signal.

TABLE 1 Chroma intra- prediction Intra-prediction scan mode for lumasignal coding mode 0 26 10 1 X (0 <= X < 35) 0 34 0 0 0 0 (Planar) 1 2634 26 26 26 (Vert.) 2 10 10 34 10 10 (Hor.) EM 3 1 1 1 34 1 (DC) 4 LM LMLM LM LM LM 5 0 26 10 1 X DM

Methods of encoding intra-prediction modes of 3 chroma signals aredescribed with reference to Table 1. A first method is to use a DerivedMode (DM) in which an intra-prediction mode of a luma signal is appliedto an intra-prediction mode of a chroma signal without change. A secondmethod is to use a coding mode (Explicit Mode (EM)) in which an actualintra-prediction mode is applied. An intra-prediction mode of a chromasignal which is encoded in the EM mode includes a planar mode Planar, aDC mode DC, a horizontal mode Hor, a vertical mode Ver, and a mode at aneighth place vertically (i.e., Ver+8 or No. 34 mode). A third method isto use an LM mode in which a chroma signal is predicted from a restoredluma signal. The most efficient methods of the three encoding methodscan be selected.

A prediction image for a signal obtained by performing prediction usingthe above-described intra-prediction mode can have a residual value withthe original image. A residual image having the residual value betweenthe prediction image and the original image can be subject to frequencydomain transform and quantization and then to entropy coding.

In order to improve entropy coding efficiency, the coefficients of thequantized image having a 2-D form can be arrayed in a 1-D form. Whenarraying the quantization coefficients again, a zigzag scan method isused in an image encoding method, such as existing H.264/AVC, but anup-right scan method is basically used in HEVC.

Furthermore, frequency domain transform can include integer transform,Discrete Cosine Transform (DCT), Discrete Sine Transform (DST), andintra-prediction mode-dependent DCT/DST.

FIG. 7 is a diagram showing an example of an up-right scan method fortransform coefficients.

When encoding quantization coefficients for a block having a specificsize, the block having a specific size can be partitioned into 4×4 sizesubblocks and encoded. Referring to FIG. 7, a 16×16 size block can bepartitioned into 16 4×4 size subblocks and encoded. In a decodingprocess, whether or not a transform coefficient is present in eachsubblock can be checked based on flag information parsed from a bitstream. For example, the flag can be significant_coeff_group_flag(sigGrpFlag). If a value of significant_coeff_group_flag is 1, it maymean that any one transform coefficient quantized into a corresponding4×4 subblock is present. In contrast, if a value ofsignificant_coeff_group_flag is 0, it may mean that any transformcoefficient quantized into a corresponding 4×4 subblock is not present.An up-right scan type has been basically used in a scan type (or scanorder) for the 4×4 subblocks shown in FIG. 7 and a scan type forsignificant_coeff_group_flag.

Although an up-right scan method has been illustrated as being appliedin FIG. 7, a scan method for a quantization coefficient includesup-right, horizontal, and vertical scans. For example, the up-right scanmethod can be basically used in inter-prediction, and the up-right,horizontal, and vertical scan methods can be selectively used inintra-prediction.

A scan type in intra-prediction can be differently selected depending onan intra-prediction mode, which can be applied to both a luma signal anda chroma signal. Table 2 below shows an example of a method ofdetermining a scan type according to an intra-prediction mode.

TABLE 2 log2TrafoSize - 2 IntraPredModeValue 0 1 2 3 0 0 0 0 0 1 0 0 0 02-5 0 0 0 0  6-14 2 2 0 0 15-21 0 0 0 0 22-30 1 1 0 0 31-35 0 0 0 0

In Table 2, IntraPredModeValue means an intra-prediction mode. Here, inthe case of a luma signal, IntraPredModeValue corresponds to a value ofIntraPredMode. In the case of a chroma signal, IntraPredModeValuecorresponds to a value of IntraPredModeC. log 2TrafoSize means that thesize of a current transform block is indicated by a log. For example,when a value of IntraPredModeValue is 1, it means a DC mode (DC;Intra_DC). When a value of log 2TrafoSize-2 is 1, it means an 8×8 sizeblock.

Furthermore, in Table 2, numbers 0, 1, and 2 determined by theintra-prediction mode ‘IntraPredModeValue’ and the current transformblock size ‘log 2TrafoSize’ indicate scan types. For example, anup-right scan type can be indicated by 0, a horizontal scan type can beindicated by 1, and a vertical scan type can be indicated by 2.

FIG. 8 is a flowchart illustrating an embodiment of a method fordetermining a scan type according to an intra-prediction mode.

The method of FIG. 8 can be performed in the encoding apparatus of FIG.1 or the decoding apparatus of FIG. 2. In the embodiment of FIG. 8,although the method of FIG. 8 is illustrated as being performed in theencoding apparatus for convenience of description, the method of FIG. 8can also be equally applied to the decoding apparatus.

In FIG. 8, IntraPredMode means an intra-prediction mode for a lumasignal, and IntraPredModeC means an intra-prediction mode for a chromasignal. IntraPredMode(C) may mean an intra-prediction mode for a lumasignal or a chroma signal depending on the components of the signal.

Referring to FIG. 8, if a current block is not an intra-prediction modeat step S800, the encoding apparatus determines that an up-right scan isused as a scan for residual signals at step S860.

If the current block is an intra-prediction mode and IntraPredModeC fora chroma signal is an LM mode at step S810, the encoding apparatusdetermines that an up-right scan is used as a scan for residual signalsat step S860.

If the current block is an intra-prediction mode and IntraPredModeC forthe chroma signal is not an LM mode at step S810, the encoding apparatusdetermines a scan type for residual signals depending onIntraPredMode(C) of the current block.

If a mode value of IntraPredMode(C) of the current block is 6 or moreand 14 or less at step S820, the encoding apparatus determines that avertical scan is used as a scan for residual signals at step S840.

If the mode value of IntraPredMode(C) is not 6 or more and 14 or lessand the mode value of IntraPredMode(C) of the current block is 22 ormore and 30 or less at step S830, the encoding apparatus determines thata horizontal scan is used as a scan for residual signals at step S850.

If not, that is, the mode value of IntraPredMode(C) is 6 or more and 14or less and is not 22 or more and 30 or less, the encoding apparatusdetermines that an up-right scan is used as a scan for residual signalsat step S860.

Meanwhile, as described above, a residual value (or residual signal orresidual) between the original image and the prediction image is subjectto frequency domain transform and quantization and then entropy coding.Here, in order to improve encoding efficiency attributable to thefrequency domain transform, integer transform, DCT, DST, andintra-prediction mode-dependent DCT/DST are selectively applieddepending on the size of a block.

Furthermore, in order to improve encoding efficiency, a transform skipalgorithm can be applied to screen content, such a document image or apresentation image of PowerPoint. If the transform skip algorithm isapplied, a residual value (or residual signal or residual) between theoriginal image and a prediction image is directly quantized and thensubject to entropy coding without a frequency transform process.Accordingly, a frequency transform process is not performed on a blockto which the transform skip algorithm has been applied.

FIG. 9 is a flowchart illustrating an example of a method of selecting afrequency transform method for residual signals (or residual image).

The method of FIG. 9 can be performed in the encoding apparatus of FIG.1 or the decoding apparatus of FIG. 2. Although the method of FIG. 9 isillustrated as being performed in the encoding apparatus in theembodiment of FIG. 9 for convenience of description, the method of FIG.9 can also be equally applied to the decoding apparatus.

Referring to FIG. 9, if a current block has been encoded in anintra-prediction mode and is not a block of a luma signal at step S900,the encoding apparatus uses integer transform or DCT as a frequencytransform method for the residual images of the luma and chroma signalsof the current block at step S990.

If the current block has been encoded in an intra-prediction mode and isa block of a luma signal at step S900, the encoding apparatus obtainsIntraPredMode for the luma signal of the current block at step S910.

The encoding apparatus checks whether or not the current block is ablock of a 4×4 size (iWidth==4) at step S920.

If, as a result of the check, the current block is not a block of a 4×4size (iWidth==4), the encoding apparatus uses integer transform or DCTas a frequency transform method for the residual images of the luma andchroma signals of the current block at step S990.

If, as a result of the check, the current block is a block of a 4×4 size(iWidth==4), the encoding apparatus checks an intra-prediction mode ofthe current block.

If, as a result of the check, a mode value of the intra-prediction modeof the current block is 2 or more and 10 or less at step S930, theencoding apparatus uses DST in a horizontal direction and DCT in avertical direction as a frequency transform method for the luma signalof the current block at step S960. DCT can be used as the frequencytransform method for the chroma signal of the current block in both thehorizontal and vertical direction.

If, as a result of the check at step S930, the mode value of theintra-prediction mode of the current block is 0 or 11 or more and 25 orless at step S940, the encoding apparatus uses DST in both thehorizontal and vertical directions as a frequency transform method forthe luma signal of the current block at step S970. DCT can be used asthe frequency transform method for the chroma signal of the currentblock in both the horizontal and vertical directions.

If, as a result of the check at step S940, the mode value of theintra-prediction mode of the current block is 26 or more and 34 or lessat step S950, the encoding apparatus uses DCT in a horizontal directionand DST in a vertical direction as a frequency transform method for theluma signal of the current block at step S980. DCT can be used as afrequency transform method for the chroma signal of the current block inboth the horizontal and vertical directions.

If, as a result of the check at step S950, the mode value of theintra-prediction mode of the current block is not 26 or more and not 34or less, the encoding apparatus used DCT in both the horizontal andvertical directions as a frequency transform method for the residualimages of the luma and chroma signals of the current block at step S990.

In FIG. 9, ‘iWidth’ is an indicator indicative of the size of atransform block, and a value of iWidth according to the size of eachtransform block can be assigned as follows.

For example, if the size of a transform block is 64×64, a value ofiWidth can be 64. If the size of a transform block is 32×32, a value ofiWidth can be 32. If the size of a transform block is 16×16, a value ofiWidth can be 16. If the size of a transform block is 8×8, a value ofiWidth can be 8. If the size of a transform block is 4×4, a value ofiWidth can be 4. If the size of a transform block is 2×2, a value ofiWidth can be 2.

In relation to the contents of FIG. 9, a transformation process forscaled transform coefficients is as follows.

In this case, input is as follows.

The width of a current transform block; nW

The height of the current transform block; nH

An array of transform coefficients having an element d_(ij); (nW×nH)array d

Information indicating whether or not the transform skip algorithm hasbeen applied to the current transform block

An index for the luma signal and the chroma signal of the currenttransform block; cldx

If cldx is 0, it means a luma signal. If cldx is 1 or cldx is 2, itmeans a chroma signal. Furthermore, if cldx is 1, it means Cb in achroma signal. If cldx is 2, it means Cr in a chroma signal.

A quantization parameter; qP

In this case, output is as follows.

An array for a residual block obtained by performing inverse transformon the scaled transform coefficients; (nW×nH) array r

If coding mode ‘PredMode’ for a current block is intra-prediction mode,a value of Log 2(nW*nH) is 4, and a value of cldx is 0, parameters‘horizTrType’ and ‘vertTrType’ are obtained through Table 3 belowdepending on intra-prediction mode of a luma signal. If not, theparameters ‘horizTrType’ and ‘vertTrType’ are set to 0.

TABLE 3 IntraPredMode 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17vertTrType 1 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 horizTrType 1 0 1 1 1 1 11 1 1 1 1 1 1 1 1 1 1 IntraPredMode 18 19 20 21 22 23 24 25 26 27 28 2930 31 32 33 34 vertTrType 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 horizTrType1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0

A residual signal for the current block is obtained according to thefollowing sequence.

First, if the transform skip algorithm for the current block has beenapplied, the following process is performed.

1. If cldx is 0, shift=13−BitDepth_(Y). If not, shift=13−BitDepth_(C).

2. An array r_(ij) (i=0 . . . (nW)−1, j=0 . . . (nH)−1) for the residualblock is set as follows. If the shift is greater than 0,r_(ij)=(d_(ij)+(1>>(shift−1)))>>shift. If not, r_(ij)=(d_(ij)<<(−shift).

If the transform skip algorithm for the current block has not beenapplied, the following process is performed.

An inverse transform process is performed on scaled transformcoefficients using values of the parameters ‘horizTrType’ and‘vertTrType’. First, the size (nW, nH) of the current block, an array‘(nW×nH) array d’ for the scaled transform coefficients, and theparameter ‘horizTrType’ are received, and an array ‘(nW×nH) array e’ isoutputted by performing 1-D inverse transform horizontally.

Next, the array ‘(nW×nH) array e’ is received, and the array ‘(nW×nH)array g’ is derived as in Equation 1.g _(ij)=Clip3(−32768, 32767, (e _(ij)+64)»7)  [Equation 1]

Next, the size (nW, nH) of the current block, the array ‘nW×nH array g’,and the parameter ‘vertTrType’ are received, and 1-dimensional inversetransform is performed horizontally.

Next, an array ‘(nW×nH) array r’ for the residual block is set as inEquation 17 below depending on cldx.r _(ij)=(f _(ij)+(1«(shift−1)))»shift  [Equation 2]

In Equation 2, the shift=20−BitDepth_(Y) when cldx is 0. If not, theshift=20−BitDepth_(C). BitDepth means the number of bits (e.g., 8 bits)of a sample for the current image.

Meanwhile, as described above, a frequency transform process is notperformed on a block to which a transform skip algorithm has beenapplied (hereinafter referred to as a transform skip block).Accordingly, a block to which an existing frequency transform processhas been performed and a transform skip block have different transformcoefficient characteristics. That is, encoding efficiency can be reducedif a transform coefficient scan method applied to a block on which anexisting frequency transform process has been performed is applied to atransform skip block. Accordingly, the present invention provides acoefficient scan method which can be applied to a transform skip block.

Embodiment 1 Method and Apparatus for Unifying a Scan Type for AllTransform Skip Blocks

FIG. 10 is a flowchart illustrating a method of deriving a scan type forresidual signals (or transform coefficients) in accordance with anembodiment of the present invention.

The method of FIG. 10 can be performed in the encoding apparatus of FIG.1 or the decoding apparatus of FIG. 2. Although the method of FIG. 10 isillustrated as being performed in the encoding apparatus in theembodiment of FIG. 10 for convenience of description, the method of FIG.10 can also be equally applied to the decoding apparatus.

Referring to FIG. 10, a scan type for the residual signals (or transformcoefficients) of a current block can be determined depending on whetheror not a transform skip algorithm has been applied to the currentresidual signal.

If, as a result of the determination at step S1000, it is determinedthat the residual signals (or transform coefficients) of the currentblock is a transform skip block, the encoding apparatus determines ahorizontal scan as the scan type for the residual signals of the currentblock at step S1010.

If, as a result of the determination at step S1000, it is determinedthat the residual signals (or transform coefficients) of the currentblock is not a transform skip block, the encoding apparatus determinesthe scan type for the residual signals of the current block based on anintra-prediction mode of the current block at step S1020. For example,any one of up-right, horizontal, and vertical scans can be derived asthe scan type for the residual signal based on an intra-prediction modeof the current block. In this case, for example, the method of FIG. 8can be used.

In the embodiment of FIG. 10, a horizontal scan has been illustrated asa scan type for the residual signals of the current block when thecurrent block is a transform skip block. However, this is only anexample, and the present invention is not limited to the example. Forexample, if a current block is a transform skip block, an up-right scanor a vertical scan may be determined as a scan type for the residualsignals of the current block.

FIG. 11 is a flowchart illustrating a method of deriving a scan type forresidual signals (or transform coefficients) in accordance with anotherembodiment of the present invention.

The method of FIG. 11 can be performed in the encoding apparatus of FIG.1 or the decoding apparatus of FIG. 2. Although the method of FIG. 11 isillustrated as being performed in the encoding apparatus in theembodiment of FIG. 11 for convenience of description, the method of FIG.11 can also be equally applied to the decoding apparatus.

Referring to FIG. 11, the encoding apparatus parses informationindicating whether or not residual signals (or transform coefficients)is present in a current block at step S1100. For example, theinformation indicating whether or not residual signals are present in acurrent block can be ‘cbf(coded block flag)’. If the residual signalsare present in the current block, that is, if one or more transformcoefficients other than 0 are included in the current block, a value ofcbf can be 1. If the residual signals are not present in the currentblock, a value of cbf can be 0.

If the information indicating whether or not residual signals arepresent in a current block indicates that the residual signals arepresent in the current block, for example, when a value of cbf is 1 atstep S1105, a next process is performed. If the information indicatingwhether or not residual signals are present in a current block indicatesthat the residual signals are not present in the current block, forexample, when a value of cbf is 0 at step S1105, the process of derivinga scan type shown in FIG. 11 is terminated at step S1110.

If the information indicating whether or not residual signals arepresent in a current block indicates that the residual signals arepresent in the current block (e.g., cbf==1), the encoding apparatusparses information indicative of a residual value in a step ofquantizating the current block at step S1115. For example, informationindicating a residual value in the step of quantizing the current blockcan be a parameter ‘cu_qp_delta’.

The information (i.e., cu_qp_delta) indicating a residual value in thestep of quantizing the current block is not related to the deriving of ascan type for the residual signals of the current block. Accordingly,step S1115 may be omitted, and next step S1120 may be performed.

The encoding apparatus sets information about the size of the currentblock at step S1120.

For example, the information about the size of the current block can beset using a parameter ‘log 2TrafoSize’. The parameter ‘log 2TrafoSize’can be a value obtained by right shifting and performing operations forthe sum of ‘log 2TrafoWidth’ indicating the width of the current blockand ‘log 2TrafoHeight’ indicating the height of the current block. Here,the parameter ‘log 2TrafoSize’ means the size of a TU block for a lumasignal.

If any one of the width and height ‘log 2TrafoWidth’ and ‘log2TrafoHeight’ of the current block is 1 (i.e., the width and height ofthe current block have a size of 2) at step S1125, the encodingapparatus sets both the width and height ‘log 2TrafoWidth’ and ‘log2TrafoHeight’ of the current block to 2 at step S1130. That is, thewidth and height of the current block are set as a size of 4.

If a transform skip algorithm has been generally applied to a currentpicture including the current block (i.e.,transform_skip_enabled_flag==1), a mode is not a mode in which transformand quantization are not performed (i.e., !cu_tranquant_bypass_flag),the coding mode of the current block has been coded in anintra-prediction mode (i.e., PredMode==MODE_INTRA), and both the widthand height ‘log 2TrafoWidth’ and ‘log 2TrafoHeight’ of the current blockare 2 at step S1135, the encoding apparatus parses informationindicating whether or not to apply transform to the current block, forexample, transform_skip_flag at step S1140.

If the coding mode of the current block has been coded in anintra-prediction mode (i.e., PredMode==MODE_INTRA) and the informationindicating whether or not to apply transform to the current blockindicates that transform is not applied to the current block, forexample, a value of transform_skip_flag is 0 (i.e., if the current blockis a transform skip block), the encoding apparatus can determine a scantype for the residual signals of the current block based on anintra-prediction mode of the current block as described above withreference to FIG. 8 at steps S1150 to S1160.

For example, if a value of cldx, that is, an indicator indicating thecolor component of the current block, is 0 at step S1150, that is, ifthe current block is a luma signal, a scan type for the residual signalsof the current block can be determined based on IntraPredMode for theluma signal of the current block at step S1155. If a value of cldx ofthe current block is not 0 at step S1150, that is, if the current blockis a chroma signal, a scan type for the residual signals of the currentblock can be determined based on IntraPredModeC for the chroma signal ofthe current block at step S1160.

Here, scanIdx can be an index value indicative of a scan type for theresidual signals of the current block. For example, if a value ofscanIdx is 0, it can indicate an up-right scan. If a value of scanIdx is1, it can indicate a horizontal scan. If a value of scanIdx is 2, it canindicate a vertical scan. ScanType can be a table indicating a scan typethat is determined by the intra-prediction modes of Table 2 and the sizeof the current block. IntraPredMode means an intra-prediction mode for aluma signal, and IntraPredModeC means an intra-prediction mode for achroma signal.

If the coding mode of the current block has been coded in anintra-prediction mode (i.e., PredMode==MODE_INTRA) and the informationindicating whether or not to apply transform to the current blockindicates that transform is applied to the current block at step S1145,for example, if a value of transform_skip_flag is 1 (i.e., the currentblock is a transform skip block), the encoding apparatus determines anyone of up-right, horizontal, and vertical scans as a scan type for theresidual signals of the current block at step S1165. For example, avalue of scanIdx can be set to 0, and an up-right scan can be determinedas a scan type for the residual signals of the current block.

In the present embodiment, an up-right scan has been determined as ascan type for the residual signals of a current block when the currentblock is a transform skip block. However, this is only an example, andthe present invention is not limited to the example. For example, if acurrent block is a transform skip, a horizontal scan (scanIdx=1) or avertical scan (scanIdx=2) may be set as a scan type for the residualsignals of the current block.

The encoding apparatus parses coefficients for the current block usingthe determined scan type at step S1170.

FIG. 12 is a diagram showing examples of scan types to which the presentinvention can be applied.

FIG. 12(a) shows an example in which a diagonal scan (or up-right scan)is applied to a 4×4 size block. Residual signals (or transformcoefficients) within the 4×4 size block can be scanned in order, such asthat of FIG. 12(a).

The diagonal scan type of FIG. 12(a) is only an example, and the presentinvention is not limited thereto. For example, the residual signals maybe scanned using a diagonal scan type in which the 4×4 size block ofFIG. 12(a) has been rotated 180 degrees to the right.

FIG. 12(b) shows an example in which a vertical scan is applied to a 4×4size block. Residual signals (or transform coefficients) within the 4×4size block can be scanned in order, such as that of FIG. 12(b).

The vertical scan type of FIG. 12(b) is only an example, and the presentinvention is not limited thereto. For example, the residual signals maybe scanned using a vertical scan type in which the 4×4 size block ofFIG. 12(b) has been rotated 180 degrees to the right.

FIG. 12(c) shows an example in which a horizontal scan is applied to a4×4 size block. Residual signals (or transform coefficients) within the4×4 size block can be scanned in order, such as that of FIG. 12(c).

The vertical scan type of FIG. 12(c) is only an example, and the presentinvention is not limited thereto. For example, the residual signals maybe scanned using a horizontal scan type in which the 4×4 size block ofFIG. 12(c) has been rotated 180 degrees to the right.

Tables 4 and 5 can be obtained by incorporating the examples of FIGS. 10and 11 into a coding syntax for a Transform Unit (TU) and residualsignals.

Table 4 shows a TU coding syntax in accordance with an embodiment of thepresent invention.

TABLE 4 Descriptor transform_unit( x0L, y0L, x0C, y0C, log2TrafoWidth,log2TrafoHeight, trafoDepth, blkIdx) { if( cbf_luma[ x0L ][ y0L ][trafoDepth ] | | cbf_cb[ x0C ][ y0C ] [ trafoDepth ] | | cbf_cr[ x0C ][y0C ][ trafoDepth ] { if( ( diff_cu_qp_delta_depth > 0 ) &&!IsCuQpDeltaCoded ) { cu_qp_della ae(v) IsCuQpDeltaCoded = 1 }log2TrafoSize = ( ( log2TrafoWidth + log2TrafoHeight ) >> 1 ) if(cbf_luma[ x0L ][ y0L ][ trafoDepth ] ) residual_coding( x0L, y0L,log2TrafoWidth, log2TrafoHeight, 0 ) if( log2TrafoSize > 2 ) { if(cbf_cb[ x0C ][ y0C ][ trafoDepth ] ) residual_coding( x0C, y0C,log2TrafoWidth − 1, log2TrafoHeight − 1, 1 ) if( cbf_cr[ x0C ][ y0C ][trafoDepth ] ) residual_coding( x0C, y0C, log2TrafoWidth − 1,log2TrafoHeight − 1, 2) } else if( blkIdx = = 3 ) { if( cbf_cb[ x0C ][y0C ][ trafoDepth ] ) residual_coding( x0C, y0C, log2TrafoWidth,log2TrafoHeight, 1 ) if( cbf_cr┌ x0C ┐┌ y0C ┐┌ trafoDepth ┐ )residual_coding( x0C, y0C, log2TrafoWidth, log2TrafoHeight, 2 ) } } }

Referring to Table 4, transform_unit indicates a bit stream for thecoefficients of one TU block. Here, whether or not to parse codinginformation (i.e., residual coding) about residual signals for the TUblock is determined based on information (cbf_luma) indicating whetheror not the residual signals are present in a luma signal and information(cbf_cb, cbf_cr) indicating whether or not the residual signals arepresent in a chroma signal.

Table 5 shows a residual signal coding syntax in accordance with anembodiment of the present invention.

TABLE 5 Descriptor residual_coding( x0, y0, log2TrafoWidth,log2TrafoHeight, cIdx) { if( log2TrafoWidth = = 1 | | log2TrafoHeight == 1 ) { log2TrafoWidth = 2 log2TrafoHeight = 2 } If(transform_skip_enabled_flag && !cu_transquant_bypass_flag && (PredMode == MODE_INTRA) && (log2TrafoWidth = = 2) && (log2TrafoHeight = = 2) )transform_skip_flag[ x0 ][ y0 ][ cIdx ] ae(v) if( PredMode = =MODE_INTRA && ! transform_skip_flag[ x0 ][ y0 ][ cIdx ] ) { if( cIdx = =0 ) scanIdx = ScanType[ log2TrafoSize − 2 ][ IntraPredMode ] elsescanIdx = ScanType[ log2TrafoSize − 2 ][ IntraPredModeC ] } else scanIdx= 0 ...

Referring to Table 5, residual_coding means a bit stream for thecoefficients of one TU block. Here, the one TU block can be a lumasignal or a chroma signal.

log 2TrafoWidth refers to the width of a current block, and log2TrafoHeight refers to the height of the current block. log 2TrafoSizerefers to a value obtained by right shifting and performing operationsfor the sum of received log 2TrafoWidth and log 2TrafoHeight and means aTU block size for a luma signal.

PredMode refers to a coding mode for a current block. PredMode is intrain the case of intra-frame coding and is inter in the case ofinter-frame coding.

scanIdx can be an index indicating a scan type for the luma signal of acurrent TU block. For example, when a value of scanIdx is 0, it canindicate an up-right scan. When a value of scanIdx is 1, it can indicatea horizontal scan. When a value of scanIdx is 2, it can indicate avertical scan.

ScanType can be a table indicating a scan type that is determined by anintra-prediction mode of Table 2 and the size of a current block. Here,“ScanType=DIAG” or “Up-right” is one example.

IntraPredMode refers to an intra-prediction mode for a luma signal, andIntraPredModeC refers to an intra-prediction mode for a chroma signal.

In the embodiments of FIGS. 10 and 11, a method of unifying a scan typefor all transform skip blocks has been described. In other words, thesame scan type has been applied to transform skip blocks. In thefollowing embodiment of the present invention, in the case of atransform skip block, a method of setting a scan type again isdescribed.

Embodiment 2 Method and Apparatus for Deriving a Scan Type for aTransform Skip Block

FIG. 13 is a flowchart illustrating a method of deriving a scan type forresidual signals (or transform coefficients) in accordance with anembodiment of the present invention.

The method of FIG. 1 can be performed in the encoding apparatus of FIG.1 or the decoding apparatus of FIG. 2. Although the method of FIG. 13 isillustrated as being performed in the encoding apparatus in theembodiment of FIG. 13 for convenience of description, the method of FIG.13 can also be equally applied to the decoding apparatus.

Referring to FIG. 13, the encoding apparatus determines a scan type forthe residual signals of a current block based on an intra-predictionmode of the current block at step S1300.

For example, any one of up-right, horizontal, and vertical scans can bederived as a scan type for the residual signals of the current blockbased on an intra-prediction mode of the current block. In this case,for example, the method of FIG. 8 can be used.

If the residual signals (or transform coefficients) of the current blockis a transform skip block at step S1310, the encoding apparatus sets ascan type for the residual signals of the current block again at stepsS1330 to S1370. If the residual signals (or transform coefficients) ofthe current block is not a transform skip block at step S1310, theprocess of deriving a scan type shown in FIG. 13 is terminated at stepS1320. Here, a scan type determined at step S1300 is used as the scantype for the residual signals of the current block.

If the residual signals of the current block correspond to a transformskip block and the scan type determined based on an intra-predictionmode of the current block is a vertical scan at step S1330, the encodingapparatus sets a scan type for the residual signals of the current blockas a horizontal direction again at step S1350.

If the residual signals of the current block correspond to a transformskip block and the scan type determined based on an intra-predictionmode of the current block is a horizontal scan at step S1340, theencoding apparatus sets a scan type for the residual signals of thecurrent block as a vertical scan again at step S1360.

If the residual signals of the current block correspond to a transformskip block and the scan type determined based on an intra-predictionmode of the current block is not any one of vertical and horizontalscans at step S1340, the encoding apparatus sets a scan type for theresidual signals of the current block as an up-right scan again at stepS1370.

The method of setting a scan type again depending on whether or not theresidual signals of a current block correspond to a transform skip blockin the embodiment of FIG. 13 can be applied in various ways. Forexample, the scan type of a luma signal which is derived using theembodiment of FIG. 13 can be equally applied to a chroma signal. Thatis, the scan type of the luma signal becomes the same as that of thechroma signal. In contrast, the embodiment of FIG. 13 can be applied toeach of a luma signal and a chroma signal. In another embodiment, a scantype for a current block may be determined based on a scan type forneighboring blocks. In yet another embodiment, in the case of atransform skip block, another scan type other than the existing scantypes (e.g., vertical, horizontal, and up-right) may be used.

FIG. 14 is a flowchart illustrating a method of deriving a scan type forresidual signals (or transform coefficients) in accordance with anotherembodiment of the present invention.

The method of FIG. 14 can be performed in the encoding apparatus of FIG.1 or the decoding apparatus of FIG. 2. Although the method of FIG. 14 isillustrated as being performed in the encoding apparatus in theembodiment of FIG. 14 for convenience of description, the method of FIG.14 can also be equally applied to the decoding apparatus.

Referring to FIG. 14, the encoding apparatus parses informationindicating whether or not residual signals (or transform coefficients)are present in a current block at step S1400.

For example, the information indicating whether or not residual signalsare present in a current block can be ‘cbf’. If residual signals arepresent in the current block, that is, if one or more transformcoefficients other than 0 are included in the current block, a value of‘cbf’ can be 1. If a residual signal is not present in the currentblock, a value of ‘cbf’ can be 0.

If the information indicating whether or not residual signals arepresent in the current block indicates that the residual signals arepresent in the current block, for example, when a value of cbf is 1 atstep S1405, a next process is performed. If the information indicatingwhether or not residual signals are present in the current blockindicates that a residual signal is not present in the current block,for example, when a value of cbf is 0 at step S1405, a next process forthe current block is terminated at step S1410.

If the information indicating whether or not residual signals arepresent in the current block indicates that the residual signals arepresent in the current block, for example, when a value of cbf is 1, theencoding apparatus parses information indicative of a residual value ina step of quantizing the current block at step S1415. For example,information indicating the residual value in the step of quantizing thecurrent block can be a parameter ‘cu_qp_delta’.

The information (i.e., cu_qp_delta) indicating the residual value in thestep of quantizing the current block is not related to the deriving of ascan type for the residual signals of the current block. Accordingly,step S1415 may be omitted, and next step S1420 may be performed.

The encoding apparatus sets information about the size of the currentblock at step S1420.

For example, the information about the size of the current block can beset using a parameter ‘log 2TrafoSize’. The parameter ‘log 2TrafoSize’can be a value obtained by right shifting and performing operation forthe sum of ‘log 2TrafoWidth’ indicative of the width of the currentblock and ‘log 2TrafoHeight’ indicative of the height of the currentblock. Here, the parameter ‘log 2TrafoSize’ means the size of a TU blockfor a luma signal.

If any one of log 2TrafoWidth and log 2TrafoHeight indicating the sizeof the current block is 1 (i.e., the width and height of the currentblock have a size of 2) at step S1425, the encoding apparatus sets bothlog 2TrafoWidth and log 2TrafoHeight of the current block to 2 at stepS1430. That is, the width and height of the current block are set to asize of 4.

If a transform skip algorithm has been generally applied to a currentpicture including the current block (i.e.,transform_skip_enabled_flag==1), a mode is not a mode in which transformand quantization are not performed (i.e., !cu_tranquant_bypass_flag),the coding mode of the current block has been coded in anintra-prediction mode (i.e., PredMode==MODE_INTRA), and both log2TrafoWidth and log 2TrafoHeight of the current block are 2 at stepS1435, the encoding apparatus parses information indicating whether ornot to apply transform to the current block, for example,transform_skip_flag at step S1440.

If the coding mode of the current block has been coded in anintra-prediction mode (i.e., PredMode==MODE_INTRA) at step S1445, theencoding apparatus can determine a scan type for the residual signals ofthe current block based on an intra-prediction mode of the current blockas described above with reference to FIG. 8 at steps S1450 to S1460.

For example, if a value of cldx, that is, an indicator indicating thecolor component of the current block, is 0 at step S1450, that is, ifthe current block is a luma signal, the encoding apparatus can determinea scan type for the residual signals of the current block based onIntraPredMode for the luma signal of the current block at step S1455. Ifa value of cldx of the current block is not 0 at step S1450, that is, ifthe current block is a chroma signal, the encoding apparatus candetermine a scan type for the residual signals of the current blockbased on IntraPredModeC for the chroma signal of the current block atstep S1460.

Here, scanIdx can be an index value indicating a scan type for theresidual signals of the current block. For example, if a value ofscanIdx is 0, it can indicate an up-right scan. If a value of scanIdx is1, it can indicate a horizontal scan. If a value of scanIdx is 2, it canindicate a vertical scan. ScanType can be a table indicating a scan typedetermined by an intra-prediction mode of Table 2 and the size of thecurrent block. IntraPredMode refers to an intra-prediction mode for aluma signal, and IntraPredModeC refers to an intra-prediction mode for achroma signal.

If the coding mode of the current block has not been coded in anintra-prediction mode at step S1445, the encoding apparatus determinesany one of up-right, horizontal, and vertical scans as a scan type forthe residual signals of the current block at step S1465. For example, avalue of scanIdx can be set to 0, and an up-right can be determined as ascan type for the residual signals of the current block.

The encoding apparatus sets the determined scan type again depending onwhether or not the current block is a transform skip block at stepS1470.

For example, the determined scan type can be set again using the methodof FIG. 13. If the current block is a transform skip block (i.e., theparsed transform_skip_flag is 1), the encoding apparatus can set ahorizontal scan as a scan type again if the determined scan type is avertical scan and set a vertical scan as a scan type again if thedetermined scan type is a horizontal scan.

The encoding apparatus parses the coefficients of the current blockusing the scan type set again at step S1475.

Tables 6 and 7 can be obtained by incorporating the examples of FIGS. 13and 14 into a coding syntax for a Transform Unit (TU) and residualsignals.

Table 6 shows a TU coding syntax in accordance with an embodiment of thepresent invention.

TABLE 6 Descriptor transform_unit( x0L, y0L, x0C, y0C, log2TrafoWidth,log2TrafoHeight, trafoDepth, blkIdx ) { if( cbf_luma[ x0L ][ y0L ][trafoDepth ] | | cbf_cb[ x0C ][ y0C ][ trafoDepth ] | | cbf_cr[ x0C ][y0C ][ trafoDepth ] { if( (diff_cu_qp_delta_depth > 0 ) &&!IsCuQpDeltaCoded ) { cu_qp_delta ae(v) IsCuQpDeltaCoded = 1 }log2TrafoSize = ( ( log2TrafoWidth + log2TrafoHeight ) >> 1 ) if(PredMode = = MODE_INTRA ) { scanIdx = ScanType┌ log2TrafoSize − 2 ┐┌IntraPredMode ┐ scanIdxC = ScanType[ log2TrafoSize − 2 ][ IntraPredModeC] } else { scanIdx = 0 scanIdxC = 0 } if( cbf_luma[ x0L ][ y0L ][trafoDepth ] ) residual_coding( x0L, y0L, log2TrafoWidth,log2TrafoHeight, scanIdx, 0 ) if( log2TrafoSizc > 2 ) { if( cbf_cb└ x0C┘└ y0C ┘└ trafoDepth ┘ ) residual_coding( x0C, y0C, log2TrafoWidth − 1,log2TrafoHeight − 1, scanIdxC, 1 ) if( cbf_cr┌ x0C ┐┌ y0C ┐┌ trafoDepth┐ ) residual_coding( x0C, y0C, log2TrafoWidth − 1, log2TrafoHeight − 1,scanIdxC, 2 ) } else if( blkIdx = = 3 ) { if( cbf_cb└ x0C ┘└ y0C ┘└trafoDepth ┘ ) residual_coding( x0C, y0C, log2TrafoWidth,log2TrafoHcight, scanIdxC, 1 ) if( cbf_cr└ x0C ┘└ y0C ┘└ trafoDepth ┘ )residual_coding( x0C, y0C, log2TrafoWidth, log2TrafoHcight, scanIdxC, 2) } } }

Referring to Table 6, transform_unit indicates a bit stream for thecoefficients of one TU block. Here, whether or not to parse codinginformation (residual coding) about residual signals for the TU block isdetermined based on information (cbf_luma) indicating whether or not theresidual signals are present in a luma signal and information (cbf_cb,cbf_cr) indicating whether or not the residual signals are present in achroma signal.

Table 7 shows a residual signal coding syntax in accordance with anembodiment of the present invention.

TABLE 7 Descriptor residual_coding( x0, y0, log2TrafoWidth,log2TrafoHeight, scanIdx, cIdx) { if( log2TrafoWidth = = 1 | |log2TrafoHeight = = 1 ) { log2TrafoWidth = 2 log2TrafoHeight = 2 } If(transform_skip_enabled_flag && !cu_transquant_bypass_flag && (PredMode == MODE_INTRA) && ( log2TrafoWidth = = 2) && (log2TrafoHeight = = 2) )transform_skip_flag┌ x0 ┐┌ y0 ┐┌ cIdx ┐ ae(v) if( transform_skip_flag└x0 ┘└ y0 ┘└ cIdx ┘ ) { scanIdx = (scanIdx = = 1) ? 2 : (scanIdx = = 2) ?1 : 0 ...

Referring to Table 7, residual_coding means a bit stream for thecoefficients of one TU block. Here, the one TU block can be a lumasignal or a chroma signal.

log 2TrafoWidth refers to the width of a current block, and log2TrafoHeight refers to the height of the current block. log 2TrafoSizemeans a result obtained by right shifting and performing operations forthe sum of received log 2TrafoWidth and log 2TrafoHeight and refers tothe size of a TU block for a luma signal.

PredMode refers to a coding mode for the current block. PredMode isintra in the case of intra-frame coding and is inter in the case ofinter-frame coding.

scanIdx can be an index indicative of a scan type for the luma signal ofa current TU block. For example, if a value of scanIdx is 0, it canindicate an up-right scan. If a value of scanIdx is 1, it can indicate ahorizontal scan. If a value of scanIdx is 2, it can indicate a verticalscan.

ScanType can be a table indicating a scan type that is determined by anintra-prediction mode of Table 2 and the size of a current block. Here,“ScanType=DIAG” or “Up-right” is only one example.

IntraPredMode refers to an intra-prediction mode for a luma signal, andIntraPredModeC refers to an intra-prediction mode for a chroma signal.

Meanwhile, the above-described embodiments can have different ranges ofapplication depending on the size of a block, the depth of a CU, or thedepth of a TU. A parameter (e.g., information about the size or depth ofa block) that determines the range of application may be set by anencoder and a decoder so that the parameter has a predetermined value ormay be set to have a predetermined value according to a profile orlevel. When an encoder writes a parameter value into a bit stream, adecoder may obtain the value from the bit stream and use the value.

If the range of application is different depending on the depth of a CU,the following three methods can be applied to the above-describedembodiments as illustrated in Table 8. The method A is applied to only adepth having a specific depth or higher, the method B is applied to onlya depth having a specific depth or lower, and the method C is applied toonly a specific depth.

Table 8 shows an example of methods of determining a range in which themethods of the present invention are applied depending on the depth of aCU (or TU). In Table 8, ‘O’ means that a corresponding method is appliedto a corresponding depth of a CU (or TU), and ‘X’ means that acorresponding method is not applied to a corresponding depth of a CU (orTU).

TABLE 8 Depth of CU (or TU) indicating range of application Method AMethod B Method C 0 X ◯ X 1 X ◯ X 2 ◯ ◯ ◯ 3 ◯ X X 4 ◯ X X

Referring to Table 8, if the depth of a CU (or TU) is 2, all the methodA, the method B, and the method C can be applied to the embodiments ofthe present invention.

If the embodiments of the present invention are not applied to all thedepths of a CU (or TU), it may be indicated using a specific indicator(e.g., flag) or may be represented by signaling a value that is 1greater than a maximum value of the depth of a CU as a value of thedepth of a CU indicating a range of application.

Furthermore, a method of determining a range in which the methods of thepresent invention are applied depending on the depth of a CU (or TU) canbe applied to each of the embodiment 1 (FIGS. 10 and 11) of the presentinvention and the embodiment 2 (FIGS. 13 and 14) of the presentinvention or a combination of the embodiments 1 and 2.

Furthermore, a method of determining a range in which the methods of thepresent invention are applied depending on the depth of a CU (or TU) canbe applied to a case where a luma signal and a chroma signal havedifferent resolutions. A method of determining a range in which afrequency transform method (or scan type) is applied when a luma signaland a chroma signal have different resolution is described below withreference to FIGS. 15 and 16.

FIG. 15 is a diagram showing an example of a difference in theresolution between a luma block and a chroma block.

Referring to FIG. 15, assuming that a chroma signal has a ¼ size of aluma signal (e.g., the luma signal has a 416×240 size and a chromasignal has a 208×120 size), a luma block 1510 having an 8×8 sizecorresponds to a chroma block 1520 having a 4×4 size.

In this case, the 8×8 size luma block 1510 can include four luma blockseach having a 4×4 size and can have intra-prediction modes in therespective 4×4 size luma blocks. In contrast, the 4×4 size chroma block1520 may not be partitioned into 2×2 size chroma blocks. The 4×4 sizechroma block 1520 can have one intra-prediction mode.

Here, if the 4×4 size chroma block 1520 has been coded in an LM mode‘Intra_FromLuma’ or the 4×4 size chroma block 1520 has been coded in anDM mode (i.e., mode in which an intra-prediction mode of a luma signalis used as an intra-prediction mode of a chroma signal without change),any one of intra-prediction modes of the four 4×4 size luma blocks canbe used as an intra-prediction mode of the 8×8 size luma block 1510 forderiving a frequency transform method (or scan type) for the residualsignals of the 4×4 size chroma block 1520.

In order to selectively apply a frequency transform method (or scantype) to the residual signals of a chroma signal, one of the followingmethods 1 to 4 can be used as a method of driving an intra-predictionmode in various ways.

1. An intra-prediction mode of a block placed at the left top of a lumasignal block can be used.

2. An intra-prediction mode of a block placed at the left top, leftbottom, or right bottom of a luma signal block can be used.

3. An average value or middle value of the four luma signal blocks canbe used.

4. An average value or middle value using intra-prediction modes of thefour luma signal blocks of a current block and chroma signal blocks ofblocks neighboring a current block can be used.

In addition to the 1 to 4 methods, an intra-prediction mode for a chromasignal can be derived in various ways.

FIG. 16 is a diagram showing another example of a difference in theresolution between a luma block and a chroma block.

Referring to FIG. 16, a luma block 1610 having a 16×16 size can have oneintra-prediction mode. In contrast, a chroma block 1620 having an 8×8size can be partitioned into four chroma blocks each having a 4×4 size.Each of the 4×4 size chroma blocks can have an intra-prediction mode.

If the 8×8 size chroma block 1620 has been coded in an LM mode‘Intra_FromLuma’ or the 8×8 size chroma block 1620 has been coded in aDM mode (i.e., mode in which an intra-prediction mode of a luma signalis used as an intra-prediction mode of a chroma signal without change),an intra-prediction mode of the 16×16 size luma block 1610 can be usedto derive a frequency transform method (or scan type) for the residualsignals of the 8×8 size chroma block 1620. In another embodiment, anintra-prediction mode can be derived from blocks (i.e., luma blocks orchroma blocks) neighboring a current block in order to derive afrequency transform method (or scan type) for the residual signals ofthe 8×8 size chroma block 1620.

The frequency transform method or the scan type can be differentlyapplied to a chroma block depending on the size of a luma block or to aluma signal image and a chroma signal image or may be differentlyapplied depending on a horizontal scan and a vertical scan.

Table 9 is an example schematically showing a combination of methods fordetermining a range of application depending on a block size, a chromasignal and a luma signal, and vertical and horizontal scans.

TABLE 9 LUMA CHROMA LUMA CHROMA HOR. VER. BLOCK SIZE BLOCK SIZE APPLIEDAPPLIED APPLIED APPLIED METHODS 4(4 × 4, 4 × 2, 2(2 × 2) ◯ or X ◯ or X ◯or X ◯ or X A 1, 2, . . . 2 × 4) 4(4 × 4, 4 × 2, 2 × 4) ◯ or X ◯ or X ◯or X ◯ or X B 1, 2, . . . 8(8 × 8, 8 × 4, ◯ or X ◯ or X ◯ or X ◯ or X C1, 2, . . . 4 × 8, 2 × 8, etc.) 16(16 × 16, 16 × 8, ◯ or X ◯ or X ◯ or X◯ or X D 1, 2, . . . 4 × 16, 2 × 16, etc.) 32(32 × 32) ◯ or X ◯ or X ◯or X ◯ or X E 1, 2, . . . 8(8 × 8, 8 × 4, 2(2 × 2) ◯ or X ◯ or X ◯ or X◯ or X F 1, 2, . . . 2 × 8, etc.) 4(4 × 4, 4 × 2, 2 × 4) ◯ or X ◯ or X ◯or X ◯ or X G 1, 2, . . . 8(8 × 8, 8 × 4, ◯ or X ◯ or X ◯ or X ◯ or X H1, 2, . . . 4 × 8, 2 × 8, etc.) 16(16 × 16, 16 × 8, ◯ or X ◯ or X ◯ or X◯ or X I 1, 2, . . . 4 × 16, 2 × 16, etc.) 32(32 × 32) ◯ or X ◯ or X ◯or X ◯ or X J 1, 2, . . . 16(16 × 16, 8 × 16, 2(2 × 2) ◯ or X ◯ or X ◯or X ◯ or X K 1, 2, . . . 4 × 16, etc.) 4(4 × 4, 4 × 2, 2 × 4) ◯ or X ◯or X ◯ or X ◯ or X L 1, 2, . . . 8(8 × 8, 8 × 4, ◯ or X ◯ or X ◯ or X ◯or X M 1, 2, . . . 4 × 8, 2 × 8, etc.) 16(16 × 16, 16 × 8, ◯ or X ◯ or X◯ or X ◯ or X N 1, 2, . . . 4 × 16, 2 × 16, etc.) 32(32 × 32) ◯ or X ◯or X ◯ or X ◯ or X O 1, 2, . . .

In the case of the method ‘G1’ of the methods listed in Table 9, if thesize of the luma block is 8(8×8, 8×4, 2×8, etc.) and the size of thechroma block is 4(4×4, 4×2, 2×4), the embodiment 1 (FIGS. 10 and 11) ofthe present invention or the embodiment 2 (FIGS. 13 and 14) of thepresent invention can be applied to a luma signal, a chroma signal, ahorizontal signal, and a vertical signal.

In the case of the method ‘M1’ of the methods listed in Table 9, if thesize of the luma block is 16(16×16, 8×16, 2×16, etc.) and the size ofthe chroma block is 4(4×4, 4×2, 2×4), the embodiment 1 (FIGS. 10 and 11)of the present invention or the embodiment 2 (FIGS. 13 and 14) of thepresent invention can be applied to a luma signal, a chroma signal, anda horizontal signal, but may not be applied to a vertical signal.

FIG. 17 is a schematic block diagram of an encoding apparatus inaccordance with an embodiment of the present invention.

Referring to FIG. 17, the encoding apparatus 1700 includes a scan typederiving module 1710 and a scanning module 1720.

The scan type deriving module 1710 derives a scan type for the residualsignals of a current block depending on whether or not the current blockis a transform skip block.

Here, the transform skip block is a block in which transform has notbeen applied to a current block and can be specified by information, forexample, transform_skip_flag indicating whether or not to applytransform to the current block.

A detailed method of deriving a scan type for the residual signals of acurrent block depending on whether or not the current block is atransform skip block has been described in detail in connection with theembodiments of this specification.

The scanning module 1720 applies the scan type, derived by the scan typederiving module 1710, to the residual signals of the current block. Forexample, the residual signals of the current block can be scanned as inthe scan type shown in FIG. 12.

FIG. 18 is a schematic block diagram of a decoding apparatus inaccordance with an embodiment of the present invention.

Referring to FIG. 18, the decoding apparatus 1800 includes a scan typederiving module 1810 and a scanning module 1820.

The scan type deriving module 1810 derives a scan type for the residualsignals of a current block depending on whether or not the current blockis a transform skip block.

Here, the transform skip block is a block in which transform has notbeen applied to a current block and can be specified by information, forexample, transform_skip_flag indicating whether or not to applytransform to the current block.

A detailed method of deriving a scan type for the residual signals of acurrent block depending on whether or not the current block is atransform skip block has been described in detail in connection with theembodiments of this specification.

The scanning module 1820 applies the scan type, derived by the scan typederiving module 1810, to the residual signals of the current block. Forexample, the residual signals of the current block can be scanned as inthe scan type shown in FIG. 12.

In the above-described embodiments, although the methods have beendescribed based on the flowcharts in the form of a series of steps orblocks, the present invention is not limited to the sequence of thesteps, and some of the steps may be performed in a different order fromthat of other steps or may be performed simultaneous to other steps.Furthermore, those skilled in the art will understand that the stepsshown in the flowchart are not exclusive and the steps may includeadditional steps or that one or more steps in the flowchart may bedeleted without affecting the scope of the present invention.

The above description is only an example of the technical spirit of thepresent invention, and those skilled in the art may change and modifythe present invention in various ways without departing from theintrinsic characteristic of the present invention. Accordingly, thedisclosed embodiments should not be construed as limiting the technicalspirit of the present invention, but should be construed as illustratingthe technical spirit of the present invention. The scope of thetechnical spirit of the present invention is not restricted by theembodiments, and the scope of the present invention should beinterpreted based on the appended claims. Accordingly, the presentinvention should be construed as covering all modifications orvariations induced from the meaning and scope of the appended claims andtheir equivalents.

The invention claimed is:
 1. A video decoding method comprising:obtaining first information indicating whether a residual signal ispresent in a current block, the current block including one or moretransform coefficient levels other than 0 when the first informationindicates that the residual signal is present in the current block; whenthe first information indicates that the residual signal is present inthe current block, obtaining the residual signal of the current blockbased on a scanning direction for the residual signal of the currentblock, the scanning direction for the residual signal of the currentblock being determined based on an intra prediction mode of the currentblock, the scanning direction for the residual signal of current blockbeing determined to be a vertical scan, a horizontal scan or an upperright scan; obtaining second information indicating whether aninverse-transform is performed on the residual signal of the currentblock; determining a transform type of the current block when the secondinformation indicates that the inverse-transform is performed on thecurrent block; obtaining residual samples of the current block byperforming the inverse-transform on the residual signal of the currentblock based on the determined transform type; obtaining predictionsamples of the current block based on the intra prediction mode of thecurrent block; obtaining reconstruction samples of the current blockusing the residual samples and prediction samples; and applying adeblocking filter to the reconstruction samples of the current block,wherein the transform type of the current block is determined to be aDCT (Discrete Cosine Transform) or a DST (Discrete Sine Transform),wherein the transform type of the current block is determinedindependently to the intra prediction mode of the current block, andwherein in response to a size of the current block not being equal to4×4, the transform type is determined to be the DCT.
 2. A video encodingmethod comprising: obtaining prediction samples of a current block;determining whether a residual signal is present in the current block,wherein when the current block including one or more transformcoefficient levels other than 0, the residual signal is present in thecurrent block; when the residual signal is present in the current block,obtaining the residual signal of the current block based on a scanningdirection for the residual signal of the current block, the scanningdirection for the residual signal of the current block being determinedbased on an intra prediction mode of the current block, the scanningdirection for the residual signal of current block being determined tobe a vertical scan, a horizontal scan or an upper right scan;determining whether an inverse-transform is performed on the residualsignal of the current block; determining a transform type of the currentblock when the inverse-transform is performed on the residual signal ofthe current block; obtaining residual samples of the current block byperforming the inverse-transform on the residual signal of the currentblock based on the determined transform type; obtaining reconstructionsamples of the current block using the residual samples and predictionsamples; applying a deblocking filter to the reconstruction samples ofthe current block; and encoding first information indicating whether theresidual signal is present in the current block and second informationindicating whether the inverse-transform is performed on the residualsignal of the current block, wherein the transform type of the currentblock is determined to be a DCT (Discrete Cosine Transform) or a DST(Discrete Sine Transform), wherein the transform type of the currentblock is determined independently to the intra prediction mode of thecurrent block.
 3. The video encoding method of claim 2, wherein inresponse to a size of the current block not being equal to 4×4, thetransform type is determined to be the DCT.
 4. A non-transitoryrecording medium storing a bitstream formed by a method of encoding avideo, the method comprising: obtaining prediction samples of a currentblock; determining whether a residual signal is present in the currentblock, wherein when the current block including one or more transformcoefficient levels other than 0, the residual signal is present in thecurrent block; when the residual signal is present in the current block,obtaining the residual signal of the current block based on a scanningdirection for the residual signal of the current block, the scanningdirection for the residual signal of the current block being determinedbased on an intra prediction mode of the current block, the scanningdirection for the residual signal of current block being determined tobe a vertical scan, a horizontal scan or an upper right scan;determining whether an inverse-transform is performed on the residualsignal of the current block; determining a transform type of the currentblock when the inverse-transform is performed on the residual signal ofthe current block; obtaining residual samples of the current block byperforming the inverse-transform on the residual signal of the currentblock based on the determined transform type; obtaining reconstructionsamples of the current block using the residual samples and predictionsamples; applying a deblocking filter to the reconstruction samples ofthe current block; and encoding first information indicating whether theresidual signal is present in the current block and second informationindicating whether the inverse-transform is performed on the residualsignal of the current block, wherein the transform type of the currentblock is determined to be a DCT (Discrete Cosine Transform) or a DST(Discrete Sine Transform), wherein the transform type of the currentblock is determined independently to the intra prediction mode of thecurrent block.
 5. The recording medium of claim 4, wherein in responseto a size of the current block not being equal to 4×4, the transformtype is determined to be the DCT.